{  Statement: http://acmp.ru/?main=task&id_task=392
   Verdict: Accepted
}
uses
    SysUtils, Math;

var
    i,n:longint;
    a:array[0..200010] of longint;

procedure find();

var
    i,kk,j,k,ans:longint;

begin
kk := 2 * n;
for i := n + 1 to kk do
    a[i] := a[i - n];
n := kk;
i := 1;
ans := 0;
kk := n shr 1;
while (i <= kk) do begin
    ans := i;
    j := i + 1;
    k := i;
    while (j <= n) and (a[k] <= a[j]) do begin
        if a[k] < a[j] then k := i else inc(k);
        inc(j);
    end;
    while i <= k do inc(i, j - k);
end;
for i := 1 to kk do
    write(a[i + ans - 1], ' ');
end;

begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
for i := 1 to n do
    read(a[i]);
find();
end.